<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文</title>
  <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
  <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
<script type="text/javascript">
function tipOpen(content) {
	$(".tipright p").text(content);
	$("#tip").fadeIn(200);
}
function tipClose() {
	$("#tip").fadeOut(200);
}
</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>仓库管理</li>
    <li>仓库浏览</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
    <form th:action="@{/storageBrowseCon/lists}" name="conditionForm" method="post">
    <ul class="tools">
      <li>仓库名称:
          <input type="text" name="cName" th:value="${conditionWare.cName}" />
      </li>
      <li> 所属区域：
          <select name="provinceId" onchange="ajaxProvince(this.value)">
              <option value="">请选择省份</option>
              <option th:each="pv :${session.plist}" th:value="${pv.id}" th:text="${pv.pName}"
                      th:selected="${conditionWare.provinceId==pv.id}" >江苏</option>
          </select>
          <select name="cityId">
              <option th:value="${cityByCid!=null}?${cityByCid.id}" th:text="${cityByCid!=null}?${cityByCid.cName}:'请选择城市'">请选择城市</option>
          </select>
      </li>
      <li class="subBut" onclick="query()"><img th:src="@{/images/t06.png}" />查询</li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>仓库名称</th>
          <th>负责人</th>
          <th>联系电话</th>
          <th>所属区域</th>
          <th>状态</th>
          <th>创建时间</th>
          <th>创建人</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      <tr th:each="ware,var : ${All.list}">
        <td th:text="${(All.pageNum-1)*All.pageSize+var.count}">1</td>
        <td th:text="${ware.cName}">南京21号仓库</td>
        <td th:text="${ware.usre.uname}">朱元璋</td>
        <td th:text="${ware.phone}">17370899727</td>
        <td th:text="${ware.province.pName}+${ware.city.cName}">江苏南京</td>
        <td th:text="${ware.state=='1'?'可用':'不可用'}">可用</td>
        <td th:text="${#dates.format(ware.creationTime,'yyyy-MM-dd')}">2013-09-09 15:05:05</td>
        <td th:text="${ware.createUser.uname}">马云</td>
        <td>
          <a th:href="@{/storage/details/?id=}+${ware.id}" class="tablelink">查看详情</a>
          </td>
        </tr>

      </tbody>
    </table>
    <div class="pagin">
        <div class="message">共<i class="blue" th:text="${All.total}">1256</i>条记录，当前显示第&nbsp;<i class="blue" th:text="${All.pageNum}">2&nbsp;</i>页</div>
        <ul class="paginList">
            <li class="paginItem" th:onclick="goPage([[${All.pageNum-1}]])"><a href="javascript:;"><span class="pagepre"></span></a></li>
            <li class="paginItem" th:onclick="goPage(1)" th:class="${All.pageNum==1?'paginItem current':'paginItem'}"><a href="javascript:;">1</a></li>

            <li th:each="p:${listPage}" th:class="${All.pageNum==p?'paginItem current':'paginItem'}" th:onclick="goPage([[${p}]])"><a th:text="${p}" href="javascript:;">2</a></li>

            <li class="paginItem" th:if="${All.pages!=1 and All.pages!=0}" th:onclick="goPage([[${All.pages}]])" th:class="${All.pageNum==All.pages?'paginItem current':'paginItem'}"><a href="javascript:;" th:text="${All.pages}" id="pages" >10</a></li>
            <li class="paginItem"  th:onclick="goPage([[${All.pageNum+1}]])"><a href="javascript:;"><span class="pagenxt"></span></a></li>
        </ul>
    </div>
  </form>
  <!-- 提示框 -->
  <div id="tip" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
    <div class="tipinfo"> <span><img th:src="@{/images/ticon.png}" /></span>
      <div class="tipright">
        <p></p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite> </div>
    </div>
    <div class="tipbtn">
      <input name="" type="button"  class="sure" value="确定" onclick="tipClose()" />
      &nbsp;
      <input name="" type="button"  class="cancel" value="取消" onclick="tipClose()" />
    </div>
  </div>
</div>
<script type="text/javascript">

    // 省市级联
    function ajaxProvince(pid){
        $.get("/erp/storage/ajaxProvince",{"pid":pid},function (data) {
            $("select[name=cityId]").html();  // 清空

            var str = "<option value=''>请选择城市</option>";
            $.each(data,function (i,e) {
                str += "<option value="+e.id+" th:selected='${conditionWare.cityId}=="+e.id+"'>"+e.cname+"</option>";
            });
            $("select[name=cityId]").html(str);  // 添加元素

        },"json");
    }

    // 表单提交
    function query(){
        $("form[name='conditionForm']").submit();
    }

    // 页面跳转
    function goPage(num){
        var cName =  $("input[name=cName]").val();
        var provinceId =  $("select[name=provinceId]").val();
        var cityId  = $("select[name=cityId]").val();

        // 最后一页
        var pages = $("#pages").text();
        if(num>=1 && num<=pages){
            location.href="/erp/storageBrowseCon/lists?pageno="+num+"&cName="+cName+"&provinceId="+provinceId+"&cityId="+cityId;
        }
    }
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
